﻿using System.Web;

using SY.WebSite.Utility;
using SY.Uap.Entity;

namespace SY.WebSite.Web
{
    /// <summary>
    /// Web Handler基类
    /// </summary>
    public class InternalWebHandler : BaseWebHandler
    {
        public User CurrentUser { get; private set; }

        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            CurrentUser = Auth.GetUser();

            if (CurrentUser == null)
            {
                context.Response.Write(new JsonTransfer().SetError("Login Required."));
                context.Response.End();

                return;
            }
        }

        public static int RequestIntParam(string key, int defaultValue = 0)
        {
            return Tools.Web.Request.GetQueryInt(key, defaultValue);
        }

        public static string RequestStringParam(string key)
        {
            return Tools.Web.Request.GetQueryString(key);
        }
    }
}